package ynu.edu.online_course.service.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ynu.edu.online_course.entity.UserExtension;
import ynu.edu.online_course.mapper.UserExtensionMapper;
import ynu.edu.online_course.service.UserExtensionService;

@Service
public class UserExtensionServiceImpl implements UserExtensionService {

    @Autowired
    private UserExtensionMapper userExtensionMapper;

    @Override
    public UserExtension getExtensionByUserId(Long userId) {
        return userExtensionMapper.findByUserId(userId);
    }

    @Override
    public void addUserExtension(UserExtension userExtension) {
        userExtensionMapper.insertUserExtension(userExtension);
    }

    @Override
    public void updateUserExtension(UserExtension userExtension) {
        userExtensionMapper.updateUserExtension(userExtension);
    }

    @Override
    public void incrementCourseCount(Long userId) {
        userExtensionMapper.incrementCourseCount(userId);
    }

    @Override
    public void decrementCourseCount(Long userId) {
        userExtensionMapper.incrementCourseCount(userId);
    }

}
